    
try:
    from IPy import IP
    import subprocess
    a=input('please input your ip address')
    ip =IP(a)
    for x in ip:
        che=subprocess.call(f'ping -c 1 {x}',shell=True)
        if che ==0:
            with open('ali.txt','a+')as fp:
                fp.write(f'{x} is used\n')
        elif che ==1:
            with open('dead.txt','a+')as fp:
                fp.write(f'{x} is not used\n')

except ValueError:
    print("输入IP地址有误！") 
except Exception:
    print("unknown faulse!")   
